// stdafx.cpp : source file that includes just the standard includes
// EnumerateTIsoforms.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"

void Tokenize(const string& str, vector<string>& tokens, const string& delimiters)
{
    // Skip delimiters at beginning.
    string::size_type lastPos = str.find_first_not_of(delimiters, 0);
    // Find first "non-delimiter".
    string::size_type pos     = str.find_first_of(delimiters, lastPos);

    while (string::npos != pos || string::npos != lastPos) {
        // Found a token, add it to the vector.
        tokens.push_back(str.substr(lastPos, pos - lastPos));
        // Skip delimiters.  Note the "not_of"
        lastPos = str.find_first_not_of(delimiters, pos);
        // Find next "non-delimiter"
        pos = str.find_first_of(delimiters, lastPos);
    }
}

string trim(string str, char sep) {
	char trimmedStr[FILENAME_MAX];
	const char* pStr = str.c_str();
    int trimStart, trimEnd;	
    for (trimStart = 0; pStr[trimStart]!= '\0'; trimStart++) {
        if (!(isspace(pStr[trimStart])) && (pStr[trimStart] != sep)) {
            break;
        }
    }
	for (trimEnd = trimStart; pStr[trimEnd]!= '\0'; trimEnd++) {
        if (isspace(pStr[trimEnd]) || (pStr[trimStart] == sep)) {
            break;
        }
    }
    strncpy(trimmedStr, &pStr[trimStart], trimEnd - trimStart);
	trimmedStr[trimEnd - trimStart] = '\0';
    return(string(trimmedStr));
}